﻿// /////////////////////////////////////////////////////////////////////
// 
//  Codeplex JSAnalyse
//  Copyright (c) 2011
//  JSAnalyse.Core   DependencyAnalysisResult.cs
// 
// /////////////////////////////////////////////////////////////////////
using System.Collections.Generic;

namespace JSAnalyse.Core.Analyser
{
    /// <summary>
    /// Dependency analysis result container
    /// </summary>
    internal class DependencyAnalysisResult : FileDependency
    {
        /// <summary>
        /// Appends the the given dependency analyses result to existing result data
        /// </summary>
        /// <param name="searchDependencies">The search dependencies.</param>
        public void AppendResult(DependencyAnalysisResult searchDependencies)
        {
            AppendListData(FileDependencies, searchDependencies.FileDependencies);
            AppendListData(WrongFileDependencies, searchDependencies.WrongFileDependencies);
        }

        /// <summary>
        /// Appends the list data.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="targetListProperty">The target list property.</param>
        /// <param name="listToAppend">The list to append.</param>
        private void AppendListData<T>(List<T> targetListProperty, IEnumerable<T> listToAppend)
        {
            if (targetListProperty == null)
            {
                targetListProperty = new List<T>();
            }
            targetListProperty.AddRange(listToAppend);
        }
    }
}
